package com.hz.house.config;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;

/**
 * <p> http client 配置
 * @author lfw
 */
@Configuration
public class HttpTemplateConfig {

	@Bean
	public RestTemplate restTemplate() {
		RestTemplate  rest =  new RestTemplate();
		rest.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
		return rest;

	}

	@Bean
	@LoadBalanced
	public RestTemplate ribbonTemplate() {
		RestTemplate  rest =  new RestTemplate();
		rest.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
		return rest;
	}

}
